class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2025-11-01",
      revision: "a26b01af8b2ac2b1b7f5f5c21a36318b2615ed8d"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_tahoe:   "4ccc8b0cbb9ced30ac12f5995f1c79970708e08d847bbd261595e1016c99fc96"
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "c70ff882bbb8ae998734eb6a2d91818dd4169444e91363becd3ecc2c3dedf4ec"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "8b3be62d07ce347cc0724a4d61b6cc32472e4d95c40a8110dd29a233ab6eefd6"
    sha256 cellar: :any_skip_relocation, sonoma:        "f06a240ee4034f1123d76f7985802ea78f5a89ba874d53ee1fb43e8fd3a6c111"
    sha256 cellar: :any_skip_relocation, arm64_linux:   "068857fde2ff040d62dd4a9bd17f728233ec7271201811cdd50cec2f8eddb9c0"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "1637a50334ce7b4e384768d1d1940b689c91123973f8eb63cb2090148ea798e0"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system bin/"searchsploit", "sendpage"
  end
end
